# coding: utf-8

from logging import *
import os


class Logger(object):
    def __init__(self, log_filename='nlp.log'):
        if not os.path.exists('logs'):
            os.mkdir('logs')
        basicConfig(level=INFO,
                    format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                    datefmt='%a, %d %b %Y %H:%M:%S',
                    filename='logs/{}'.format(log_filename),
                    filemode='a')
        console = StreamHandler()
        console.setLevel(INFO)
        formatter = Formatter('%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s')
        console.setFormatter(formatter)
        logger = getLogger()
        logger.addHandler(console)

    def info(self, s):
        info(s)

    def error(self, s):
        error(s)

